removed default initialization check, people must use gtk_type_init();
authorTim Janik <timj@gtk.org>
Sun, 29 Nov 1998 06:29:40 +0000 (06:29 +0000)
committerTim Janik <timj@src.gnome.org>
Sun, 29 Nov 1998 06:29:40 +0000 (06:29 +0000)
Sun Nov 29 06:12:01 1998  Tim Janik  <timj@gtk.org>

        * gtk/gtktypeutils.c (gtk_type_unique): removed default initialization
        check, people must use gtk_type_init();

        * gtk/gtkwidget.h:
        * gtk/gtkwidget.c: added gtk_widget_set_composite_name() which is meant
        for internal use by containers, that want to assign specific composite
        names to their composite children.
        added gtk_widget_get_composite_name() which will return a newly
        allocated string, containing the composite name of a widget. valid
        composite names can only be retrived from widgets that have a parent
        assigned and are flagged as GTK_COMPOSITE_CHILD.

        * gtk/gtkcontainer.h:
        * gtk/gtkcontainer.c: added a new function
        gtk_container_child_default_composite_name() which will return a
        newly allocated string, holding the composite name of a containers
        child. a default implementation is provided which will compose the
        composite name out of the widgets type and its sequential children
        id. this implementation can be overidden through a new class function
        *(composite_name)().

12 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkcontainer.c
gtk/gtkcontainer.h
gtk/gtktypeutils.c
gtk/gtkwidget.c
gtk/gtkwidget.h

index fc9816810f5f49e178515eb5d33908a1e5a01e1c..fbff378b66245d8849b90131ee45cc5a4ee7c7ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+Sun Nov 29 06:12:01 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_unique): removed default initialization
+       check, people must use gtk_type_init();
+
+       * gtk/gtkwidget.h: 
+       * gtk/gtkwidget.c: added gtk_widget_set_composite_name() which is meant
+       for internal use by containers, that want to assign specific composite
+       names to their composite children.
+       added gtk_widget_get_composite_name() which will return a newly
+       allocated string, containing the composite name of a widget. valid
+       composite names can only be retrived from widgets that have a parent
+       assigned and are flagged as GTK_COMPOSITE_CHILD.
+
+       * gtk/gtkcontainer.h:
+       * gtk/gtkcontainer.c: added a new function
+       gtk_container_child_default_composite_name() which will return a
+       newly allocated string, holding the composite name of a containers
+       child. a default implementation is provided which will compose the
+       composite name out of the widgets type and its sequential children
+       id. this implementation can be overidden through a new class function
+       *(composite_name)().
+
 Sat Nov 28 10:57:59 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_expose_event): Removed bogus
index fc9816810f5f49e178515eb5d33908a1e5a01e1c..fbff378b66245d8849b90131ee45cc5a4ee7c7ed 100644 (file)
@@ -1,3 +1,26 @@
+Sun Nov 29 06:12:01 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_unique): removed default initialization
+       check, people must use gtk_type_init();
+
+       * gtk/gtkwidget.h: 
+       * gtk/gtkwidget.c: added gtk_widget_set_composite_name() which is meant
+       for internal use by containers, that want to assign specific composite
+       names to their composite children.
+       added gtk_widget_get_composite_name() which will return a newly
+       allocated string, containing the composite name of a widget. valid
+       composite names can only be retrived from widgets that have a parent
+       assigned and are flagged as GTK_COMPOSITE_CHILD.
+
+       * gtk/gtkcontainer.h:
+       * gtk/gtkcontainer.c: added a new function
+       gtk_container_child_default_composite_name() which will return a
+       newly allocated string, holding the composite name of a containers
+       child. a default implementation is provided which will compose the
+       composite name out of the widgets type and its sequential children
+       id. this implementation can be overidden through a new class function
+       *(composite_name)().
+
 Sat Nov 28 10:57:59 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_expose_event): Removed bogus
index fc9816810f5f49e178515eb5d33908a1e5a01e1c..fbff378b66245d8849b90131ee45cc5a4ee7c7ed 100644 (file)
@@ -1,3 +1,26 @@
+Sun Nov 29 06:12:01 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_unique): removed default initialization
+       check, people must use gtk_type_init();
+
+       * gtk/gtkwidget.h: 
+       * gtk/gtkwidget.c: added gtk_widget_set_composite_name() which is meant
+       for internal use by containers, that want to assign specific composite
+       names to their composite children.
+       added gtk_widget_get_composite_name() which will return a newly
+       allocated string, containing the composite name of a widget. valid
+       composite names can only be retrived from widgets that have a parent
+       assigned and are flagged as GTK_COMPOSITE_CHILD.
+
+       * gtk/gtkcontainer.h:
+       * gtk/gtkcontainer.c: added a new function
+       gtk_container_child_default_composite_name() which will return a
+       newly allocated string, holding the composite name of a containers
+       child. a default implementation is provided which will compose the
+       composite name out of the widgets type and its sequential children
+       id. this implementation can be overidden through a new class function
+       *(composite_name)().
+
 Sat Nov 28 10:57:59 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_expose_event): Removed bogus
index fc9816810f5f49e178515eb5d33908a1e5a01e1c..fbff378b66245d8849b90131ee45cc5a4ee7c7ed 100644 (file)
@@ -1,3 +1,26 @@
+Sun Nov 29 06:12:01 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_unique): removed default initialization
+       check, people must use gtk_type_init();
+
+       * gtk/gtkwidget.h: 
+       * gtk/gtkwidget.c: added gtk_widget_set_composite_name() which is meant
+       for internal use by containers, that want to assign specific composite
+       names to their composite children.
+       added gtk_widget_get_composite_name() which will return a newly
+       allocated string, containing the composite name of a widget. valid
+       composite names can only be retrived from widgets that have a parent
+       assigned and are flagged as GTK_COMPOSITE_CHILD.
+
+       * gtk/gtkcontainer.h:
+       * gtk/gtkcontainer.c: added a new function
+       gtk_container_child_default_composite_name() which will return a
+       newly allocated string, holding the composite name of a containers
+       child. a default implementation is provided which will compose the
+       composite name out of the widgets type and its sequential children
+       id. this implementation can be overidden through a new class function
+       *(composite_name)().
+
 Sat Nov 28 10:57:59 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_expose_event): Removed bogus
index fc9816810f5f49e178515eb5d33908a1e5a01e1c..fbff378b66245d8849b90131ee45cc5a4ee7c7ed 100644 (file)
@@ -1,3 +1,26 @@
+Sun Nov 29 06:12:01 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_unique): removed default initialization
+       check, people must use gtk_type_init();
+
+       * gtk/gtkwidget.h: 
+       * gtk/gtkwidget.c: added gtk_widget_set_composite_name() which is meant
+       for internal use by containers, that want to assign specific composite
+       names to their composite children.
+       added gtk_widget_get_composite_name() which will return a newly
+       allocated string, containing the composite name of a widget. valid
+       composite names can only be retrived from widgets that have a parent
+       assigned and are flagged as GTK_COMPOSITE_CHILD.
+
+       * gtk/gtkcontainer.h:
+       * gtk/gtkcontainer.c: added a new function
+       gtk_container_child_default_composite_name() which will return a
+       newly allocated string, holding the composite name of a containers
+       child. a default implementation is provided which will compose the
+       composite name out of the widgets type and its sequential children
+       id. this implementation can be overidden through a new class function
+       *(composite_name)().
+
 Sat Nov 28 10:57:59 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_expose_event): Removed bogus
index fc9816810f5f49e178515eb5d33908a1e5a01e1c..fbff378b66245d8849b90131ee45cc5a4ee7c7ed 100644 (file)
@@ -1,3 +1,26 @@
+Sun Nov 29 06:12:01 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_unique): removed default initialization
+       check, people must use gtk_type_init();
+
+       * gtk/gtkwidget.h: 
+       * gtk/gtkwidget.c: added gtk_widget_set_composite_name() which is meant
+       for internal use by containers, that want to assign specific composite
+       names to their composite children.
+       added gtk_widget_get_composite_name() which will return a newly
+       allocated string, containing the composite name of a widget. valid
+       composite names can only be retrived from widgets that have a parent
+       assigned and are flagged as GTK_COMPOSITE_CHILD.
+
+       * gtk/gtkcontainer.h:
+       * gtk/gtkcontainer.c: added a new function
+       gtk_container_child_default_composite_name() which will return a
+       newly allocated string, holding the composite name of a containers
+       child. a default implementation is provided which will compose the
+       composite name out of the widgets type and its sequential children
+       id. this implementation can be overidden through a new class function
+       *(composite_name)().
+
 Sat Nov 28 10:57:59 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_expose_event): Removed bogus
index fc9816810f5f49e178515eb5d33908a1e5a01e1c..fbff378b66245d8849b90131ee45cc5a4ee7c7ed 100644 (file)
@@ -1,3 +1,26 @@
+Sun Nov 29 06:12:01 1998  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtktypeutils.c (gtk_type_unique): removed default initialization
+       check, people must use gtk_type_init();
+
+       * gtk/gtkwidget.h: 
+       * gtk/gtkwidget.c: added gtk_widget_set_composite_name() which is meant
+       for internal use by containers, that want to assign specific composite
+       names to their composite children.
+       added gtk_widget_get_composite_name() which will return a newly
+       allocated string, containing the composite name of a widget. valid
+       composite names can only be retrived from widgets that have a parent
+       assigned and are flagged as GTK_COMPOSITE_CHILD.
+
+       * gtk/gtkcontainer.h:
+       * gtk/gtkcontainer.c: added a new function
+       gtk_container_child_default_composite_name() which will return a
+       newly allocated string, holding the composite name of a containers
+       child. a default implementation is provided which will compose the
+       composite name out of the widgets type and its sequential children
+       id. this implementation can be overidden through a new class function
+       *(composite_name)().
+
 Sat Nov 28 10:57:59 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkwindow.c (gtk_window_expose_event): Removed bogus
index 52f1c4a30b0be9414615a74fce84a4b3fdf9fd79..74bbaeca828f8a327237a6381aad6211fec33a1e 100644 (file)
@@ -89,6 +89,9 @@ static void gtk_container_children_callback (GtkWidget         *widget,
 static void gtk_container_show_all          (GtkWidget         *widget);
 static void gtk_container_hide_all          (GtkWidget         *widget);
 
+static gchar* gtk_container_child_default_composite_name (GtkContainer *container,
+                                                         GtkWidget    *child);
+
 
 
 static guint container_signals[LAST_SIGNAL] = { 0 };
@@ -212,6 +215,7 @@ gtk_container_class_init (GtkContainerClass *class)
   class->focus = gtk_container_real_focus;
   class->set_focus_child = gtk_container_real_set_focus_child;
   class->child_type = NULL;
+  class->composite_name = gtk_container_child_default_composite_name;
 }
 
 GtkType
@@ -1254,7 +1258,7 @@ gtk_container_unregister_toplevel (GtkContainer *container)
   gtk_widget_unref (GTK_WIDGET (container));
 }
 
-GList *
+GList*
 gtk_container_get_toplevels (void)
 {
   /* XXX: fixme we should ref all these widgets and duplicate
@@ -1263,6 +1267,83 @@ gtk_container_get_toplevels (void)
   return toplevel_list;
 }
 
+static void
+gtk_container_child_position_callback (GtkWidget *widget,
+                                      gpointer   client_data)
+{
+  struct {
+    GtkWidget *child;
+    guint i;
+    guint index;
+  } *data = client_data;
+
+  data->i++;
+  if (data->child == widget)
+    data->index = data->i;
+}
+
+static gchar*
+gtk_container_child_default_composite_name (GtkContainer *container,
+                                           GtkWidget    *child)
+{
+  struct {
+    GtkWidget *child;
+    guint i;
+    guint index;
+  } data;
+  gchar *name;
+
+  /* fallback implementation */
+  data.child = child;
+  data.i = 0;
+  data.index = 0;
+  gtk_container_forall (container,
+                       gtk_container_child_position_callback,
+                       &data);
+  
+  name = g_strdup_printf ("%s-%u",
+                         gtk_type_name (GTK_OBJECT_TYPE (child)),
+                         data.index);
+
+  return name;
+}
+
+gchar*
+gtk_container_child_composite_name (GtkContainer *container,
+                                   GtkWidget    *child)
+{
+  g_return_val_if_fail (container != NULL, NULL);
+  g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
+  g_return_val_if_fail (child != NULL, NULL);
+  g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
+  g_return_val_if_fail (child->parent == GTK_WIDGET (container), NULL);
+
+  if (GTK_WIDGET_COMPOSITE_CHILD (child))
+    {
+      static GQuark quark_composite_name = 0;
+      gchar *name;
+
+      if (!quark_composite_name)
+       quark_composite_name = g_quark_from_static_string ("gtk-composite-name");
+
+      name = gtk_object_get_data_by_id (GTK_OBJECT (child), quark_composite_name);
+      if (!name)
+       {
+         GtkContainerClass *class;
+
+         class = GTK_CONTAINER_CLASS (GTK_OBJECT (container)->klass);
+         if (class->composite_name)
+           name = class->composite_name (container, child);
+       }
+      else
+       name = g_strdup (name);
+
+      return name;
+    }
+  
+  return NULL;
+}
+
 void
 gtk_container_real_set_focus_child (GtkContainer     *container,
                                    GtkWidget        *child)
index 6f518bb46fed1dc26046e51734b3eb43c85f6b6f..a212f255d2996d084e8a98da9f0199614e12ca22 100644 (file)
@@ -87,6 +87,8 @@ struct _GtkContainerClass
                                 GtkWidget      *child,
                                 GtkArg         *arg,
                                 guint           arg_id);
+  gchar*  (*composite_name)    (GtkContainer   *container,
+                                GtkWidget      *child);
 };
 
 /* Application-level methods */
@@ -211,6 +213,8 @@ gchar*  gtk_container_child_arg_get_info   (GtkType       object_type,
 void    gtk_container_forall              (GtkContainer *container,
                                            GtkCallback   callback,
                                            gpointer      callback_data);
+gchar* gtk_container_child_composite_name (GtkContainer *container,
+                                           GtkWidget    *child);
 
 
 /* Deprecated methods */
index 41a5ec1f0d6d21ac73eda1b8b34adf0e36413ece..c9b415ad7e01df154b2611e66951eea0e9ded605 100644 (file)
@@ -20,7 +20,7 @@
 #include "gtktypeutils.h"
 
 
-#define        TYPE_NODES_BLOCK_SIZE   (200)
+#define        TYPE_NODES_BLOCK_SIZE   (35)  /* needs to be > GTK_TYPE_FUNDAMENTAL_MAX */
 
 typedef struct _GtkTypeNode GtkTypeNode;
 
@@ -39,16 +39,20 @@ struct _GtkTypeNode
 
 
 #define        LOOKUP_TYPE_NODE(node_var, type)        { \
-  if (type > 0) \
-  { \
-    register GtkType sqn = GTK_TYPE_SEQNO (type); \
-    if (sqn < n_type_nodes) \
-      node_var = type_nodes + sqn; \
-    else \
-      node_var = NULL; \
-  } \
-  else \
-    node_var = NULL; \
+    GtkTypeNode *__node = NULL; \
+    GtkType sqn = GTK_TYPE_SEQNO (type); \
+    if (sqn > 0) \
+      { \
+       sqn--; \
+       if (sqn < GTK_TYPE_FUNDAMENTAL_MAX) \
+         { \
+           if (sqn < n_ftype_nodes) \
+             __node = type_nodes + sqn; \
+         } \
+       else if (sqn < n_type_nodes) \
+         __node = type_nodes + sqn; \
+      } \
+    node_var = __node; \
 }
 
 static void  gtk_type_class_init               (GtkType      node_type);
@@ -59,23 +63,23 @@ static void  gtk_type_init_builtin_types    (void);
 
 static GtkTypeNode *type_nodes = NULL;
 static guint       n_type_nodes = 0;
+static guint       n_ftype_nodes = 0;
 static GHashTable  *type_name_2_type_ht = NULL;
 
 
 static GtkTypeNode*
-gtk_type_node_next_and_invalidate (void)
+gtk_type_node_next_and_invalidate (GtkType parent_type)
 {
-  static guint n_free_type_nodes = 0;
-  register GtkTypeNode *node;
-  register GtkType new_type;
+  static guint n_free_type_nodes = 0;
+  GtkTypeNode *node;
   
   /* don't keep *any* GtkTypeNode pointers across invokation of this function!!!
    */
   
   if (n_free_type_nodes == 0)
     {
-      register guint i;
-      register guint size;
+      guint i;
+      guint size;
       
       /* nearest pow
        */
@@ -91,22 +95,28 @@ gtk_type_node_next_and_invalidate (void)
       n_free_type_nodes = size / sizeof (GtkTypeNode) - n_type_nodes;
       
       memset (type_nodes + n_type_nodes, 0, n_free_type_nodes * sizeof (GtkTypeNode));
+      if (!n_type_nodes)
+       {
+         n_type_nodes = GTK_TYPE_FUNDAMENTAL_MAX;
+         n_free_type_nodes -= GTK_TYPE_FUNDAMENTAL_MAX;
+       }
     }
-  
-  new_type = n_type_nodes++;
-  n_free_type_nodes--;
-  
-  /* This can't be used here - new_type can be over 256!
-   * LOOKUP_TYPE_NODE (node, new_type);
-   * Code copied from above (we may assume we are all right here):
-   */
 
-  if(new_type == 0) 
-    return NULL;
-  node = type_nodes + new_type;
+  if (!parent_type)
+    {
+      g_assert (n_ftype_nodes < GTK_TYPE_FUNDAMENTAL_MAX); /* paranoid */
 
-  if (node)
-    node->type = new_type;
+      node = type_nodes + n_ftype_nodes;
+      n_ftype_nodes++;
+      node->type = n_ftype_nodes;
+    }
+  else
+    {
+      node = type_nodes + n_type_nodes;
+      n_type_nodes++;
+      n_free_type_nodes--;
+      node->type = GTK_TYPE_MAKE (parent_type, n_type_nodes);
+    }
   
   return node;
 }
@@ -116,12 +126,8 @@ gtk_type_init (void)
 {
   if (n_type_nodes == 0)
     {
-      GtkTypeNode *zero;
-      
       g_assert (sizeof (GtkType) >= 4);
-      
-      zero = gtk_type_node_next_and_invalidate ();
-      g_assert (zero == NULL);
+      g_assert (TYPE_NODES_BLOCK_SIZE > GTK_TYPE_FUNDAMENTAL_MAX);
       
       type_name_2_type_ht = g_hash_table_new ((GHashFunc) gtk_type_name_hash,
                                              (GCompareFunc) gtk_type_name_compare);
@@ -182,16 +188,16 @@ gtk_type_create (GtkType      parent_type,
   
   /* relookup pointers afterwards.
    */
-  new_node = gtk_type_node_next_and_invalidate ();
+  new_node = gtk_type_node_next_and_invalidate (parent_type);
   
   if (parent_type)
     {
-      new_node->type = GTK_TYPE_MAKE (parent_type, new_node->type);
+      g_assert (GTK_TYPE_SEQNO (new_node->type) > GTK_TYPE_FUNDAMENTAL_MAX);
       LOOKUP_TYPE_NODE (parent, parent_type);
     }
   else
     {
-      g_assert (new_node->type <= 0xff);
+      g_assert (new_node->type <= GTK_TYPE_FUNDAMENTAL_MAX);
       parent = NULL;
     }
   
@@ -232,9 +238,13 @@ gtk_type_unique (GtkType      parent_type,
   g_return_val_if_fail (type_info != NULL, 0);
   g_return_val_if_fail (type_info->type_name != NULL, 0);
   
-  if (n_type_nodes == 0)
-    gtk_type_init ();
-  
+  if (!parent_type && n_ftype_nodes >= GTK_TYPE_FUNDAMENTAL_MAX)
+    {
+      g_warning ("gtk_type_unique(): maximum amount of fundamental types reached, "
+                "try increasing GTK_TYPE_FUNDAMENTAL_MAX");
+      return 0;
+    }
+
   type_name = g_strdup (type_info->type_name);
   
   /* relookup pointers afterwards.
@@ -491,12 +501,12 @@ gtk_type_is_a (GtkType type,
     return TRUE;
   else
     {
-      register GtkTypeNode *node;
+      GtkTypeNode *node;
       
       LOOKUP_TYPE_NODE (node, type);
       if (node)
        {
-         register GtkTypeNode *a_node;
+         GtkTypeNode *a_node;
          
          LOOKUP_TYPE_NODE (a_node, is_a_type);
          if (a_node)
@@ -572,7 +582,7 @@ gtk_type_class_init (GtkType type)
          
          for (walk = slist; walk; walk = walk->next)
            {
-             register GtkClassInitFunc base_class_init;
+             GtkClassInitFunc base_class_init;
              
              base_class_init = walk->data;
              base_class_init (node->klass);
@@ -948,7 +958,7 @@ gtk_type_init_builtin_types (void)
       
       /* relookup pointers afterwards.
        */
-      type_id = gtk_type_register_intern (fundamental_info[i].name, GTK_TYPE_INVALID, NULL);
+      type_id = gtk_type_register_intern (fundamental_info[i].name, 0, NULL);
       
       g_assert (type_id == fundamental_info[i].type_id);
     }
@@ -967,7 +977,7 @@ gtk_type_init_builtin_types (void)
                                          builtin_info[i].parent,
                                          builtin_info[i].values);
       
-      g_assert (type_id != GTK_TYPE_INVALID);
+      g_assert (GTK_TYPE_SEQNO (type_id) > GTK_TYPE_FUNDAMENTAL_MAX);
       
       (*builtin_info[i].type_id) = type_id;
     }
index 2b1a80038af25ef00904f35942210266362cf790..de9339ec524520c6bc23d88be9436e1613024b7f 100644 (file)
@@ -1642,7 +1642,7 @@ struct _GtkDrawData {
 static GMemChunk   *draw_data_mem_chunk = NULL;
 static GSList      *draw_data_free_list = NULL;
 static const gchar *draw_data_key  = "gtk-draw-data";
-static guint        draw_data_key_id = 0;
+static GQuark       draw_data_key_id = 0;
 
 static gint gtk_widget_idle_draw (gpointer data);
 
@@ -3812,6 +3812,52 @@ gtk_widget_is_ancestor (GtkWidget *widget,
   return FALSE;
 }
 
+static GQuark quark_composite_name = 0;
+
+void
+gtk_widget_set_composite_name (GtkWidget *widget,
+                              gchar     *name)
+{
+  g_return_if_fail (widget != NULL);
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (GTK_WIDGET_COMPOSITE_CHILD (widget));
+  g_return_if_fail (name != NULL);
+
+  if (!quark_composite_name)
+    quark_composite_name = g_quark_from_static_string ("gtk-composite-name");
+
+  gtk_object_set_data_by_id_full (GTK_OBJECT (widget),
+                                 quark_composite_name,
+                                 g_strdup (name),
+                                 g_free);
+}
+
+gchar*
+gtk_widget_get_composite_name (GtkWidget *widget)
+{
+  g_return_val_if_fail (widget != NULL, NULL);
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+  if (GTK_WIDGET_COMPOSITE_CHILD (widget) && widget->parent)
+    return gtk_container_child_composite_name (GTK_CONTAINER (widget->parent),
+                                              widget);
+  else
+    return NULL;
+}
+
+void
+gtk_widget_push_composite_child (void)
+{
+  composite_child_stack++;
+}
+
+void
+gtk_widget_pop_composite_child (void)
+{
+  if (composite_child_stack)
+    composite_child_stack--;
+}
+
 /*****************************************
  * gtk_widget_push_colormap:
  *
@@ -3844,19 +3890,6 @@ gtk_widget_push_visual (GdkVisual *visual)
   visual_stack = g_slist_prepend (visual_stack, visual);
 }
 
-void
-gtk_widget_push_composite_child (void)
-{
-  composite_child_stack++;
-}
-
-void
-gtk_widget_pop_composite_child (void)
-{
-  if (composite_child_stack)
-    composite_child_stack--;
-}
-
 /*****************************************
  * gtk_widget_pop_colormap:
  *
index 9c135d8b2d96309302d6b450e317646cbe35d7c7..b2ffc0bd11de33393df221faa5563cd1412c77d5 100644 (file)
@@ -75,11 +75,11 @@ typedef enum
 #define GTK_WIDGET_REALIZED(wid)         ((GTK_WIDGET_FLAGS (wid) & GTK_REALIZED) != 0)
 #define GTK_WIDGET_MAPPED(wid)           ((GTK_WIDGET_FLAGS (wid) & GTK_MAPPED) != 0)
 #define GTK_WIDGET_VISIBLE(wid)                  ((GTK_WIDGET_FLAGS (wid) & GTK_VISIBLE) != 0)
-#define GTK_WIDGET_DRAWABLE(wid)         ((GTK_WIDGET_VISIBLE (wid) && GTK_WIDGET_MAPPED (wid)) != 0)
+#define GTK_WIDGET_DRAWABLE(wid)         (GTK_WIDGET_VISIBLE (wid) && GTK_WIDGET_MAPPED (wid))
 #define GTK_WIDGET_SENSITIVE(wid)        ((GTK_WIDGET_FLAGS (wid) & GTK_SENSITIVE) != 0)
 #define GTK_WIDGET_PARENT_SENSITIVE(wid)  ((GTK_WIDGET_FLAGS (wid) & GTK_PARENT_SENSITIVE) != 0)
-#define GTK_WIDGET_IS_SENSITIVE(wid)     (((GTK_WIDGET_SENSITIVE (wid) && \
-                                           GTK_WIDGET_PARENT_SENSITIVE (wid)) != 0) != 0)
+#define GTK_WIDGET_IS_SENSITIVE(wid)     (GTK_WIDGET_SENSITIVE (wid) && \
+                                          GTK_WIDGET_PARENT_SENSITIVE (wid))
 #define GTK_WIDGET_CAN_FOCUS(wid)        ((GTK_WIDGET_FLAGS (wid) & GTK_CAN_FOCUS) != 0)
 #define GTK_WIDGET_HAS_FOCUS(wid)        ((GTK_WIDGET_FLAGS (wid) & GTK_HAS_FOCUS) != 0)
 #define GTK_WIDGET_CAN_DEFAULT(wid)      ((GTK_WIDGET_FLAGS (wid) & GTK_CAN_DEFAULT) != 0)
@@ -542,6 +542,13 @@ void          gtk_widget_restore_default_style (GtkWidget  *widget);
 void       gtk_widget_modify_style      (GtkWidget      *widget,
                                         GtkRcStyle     *style);
 
+/* handle composite names for GTK_COMPOSITE_CHILD widgets,
+ * the returned name is newly allocated.
+ */
+void   gtk_widget_set_composite_name   (GtkWidget      *widget,
+                                        gchar          *name);
+gchar* gtk_widget_get_composite_name   (GtkWidget      *widget);
+     
 /* Descend recursively and set rc-style on all widgets without user styles */
 void       gtk_widget_reset_rc_styles   (GtkWidget      *widget);